package cn.edu.scau.cmi.liweihang.adapter;

import java.util.ArrayList;
import java.util.List;

import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class Control {
	@FXML
	private TextField numberField;
	@FXML
	private TextField nameField;
	@FXML
	private TextArea textarea;
	
	private static int count=0;
	
	private int number=0;
	
	private String name=null;
	
	private Student [] student=new Student[100];
	
	
	private List<Integer> list=new ArrayList();

	public void sendAction() {
		Student st=new Student();
//		System.out.println(count);
		number=Integer.parseInt(numberField.getText());
		list.add(number);
		st.setNumber(number);
		name=nameField.getText();
		st.setName(name);
		student[count]=st;
//		System.out.println(Student[count].getNumber()+" "+Student[count].getName());		
		count++;
//		System.out.println(count);
//		for(int i=0;i<count;i++) {
//			System.out.println(Student[i].getNumber()+" "+Student[i].getName());
//			System.out.println(list);
//		}
	}

	public void sortAction() {	
		int temp=0;
//		classAdapter ca=new classAdapter();
//		ca.doSort(list);
		objectAdapter oa=new objectAdapter();
		oa.doSort(list);
		for(int i=0;i<list.size();i++) {
			temp=list.get(i);
			for(int j=0;j<list.size();j++) {
				if(temp==student[j].getNumber())
					textarea.appendText(student[j].getNumber()+" "+student[j].getName()+"\n");
			}
		}
	}
}
